home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 076-100 / disk_092 / as6502 / assm0.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  6KB  |  229 lines

  1. #include "stdio.h"
  2. #include "assm.d1"
  3. #include "ctype.h"
  4.  
  5. /*  Assembler for the MOS Technology 650X series of microprocessors
  6.  *  Written by J. H. Van Ornum (201) 949-1781
  7.  *        AT&T Bell Laboratories
  8.  *         Holmdel, NJ
  9.  */
  10.  
  11. FILE    *optr;
  12. FILE    *iptr;
  13. int    dflag;            /* debug flag */
  14. int    errcnt;            /* error counter */
  15. char    hex[5];            /* hexadecimal character buffer */
  16. int    iflag;            /* ignore .nlst flag */
  17. int    lablptr;        /* label pointer into symbol table */
  18. int    lflag;            /* disable listing flag */
  19. int    loccnt;            /* location counter    */
  20. int    nflag;            /* normal/split address mode */
  21. int    mflag;            /* generate MOS Technology object format */
  22. int    nxt_free;        /* next free location in symtab */
  23. int    objcnt;            /* object byte counter */
  24. int    oflag;            /* object output flag */
  25. int    opflg;            /* operation code flags */
  26. int    opval;            /* operation code value */
  27. int    pass;            /* pass counter        */
  28. char    prlnbuf[LAST_CH_POS+1]; /* print line buffer    */
  29. int    sflag;            /* symbol table output flag */
  30. int    slnum;            /* source line number counter */
  31. char    *symtab;        /* symbol table        */
  32.                 /* struct sym_tab        */
  33.                 /* {    char    size;        */
  34.                 /*    char    chars[size];    */
  35.                 /*    char    flag;        */
  36.                 /*    int    value;        */
  37.                 /*    int    line defined    */
  38.                 /*    char    # references    */
  39.                 /*    int    line referenced    */
  40.                 /* (above occurs 0 or more times*/
  41.                 /* }                */
  42. unsigned size;            /* symbol table size         */
  43. char    symbol[SBOLSZ];        /* temporary symbol storage    */
  44. int    udtype;            /* undefined symbol type    */
  45. int    undef;            /* undefined symbol in expression flg  */
  46. int    value;            /* operand field value */
  47. char    zpref;            /* zero page reference flag    */
  48. /* added by Joel Swank 12/86   */
  49. int    pagect;            /* count of pages               */
  50. int    paglin;            /* lines printed on current page */
  51. int    pagesize;        /* maximum lines per page       */
  52. int    linesize;        /* maximum characters oer line  */
  53. int    titlesize;        /* maximum characters oer line  */
  54. char    titlbuf[100];        /* buffer for title from .page  */
  55. char    syspc[80];        /* variable filler for heading  */
  56. char    *date;            /* pointer to formatted date string */
  57.  
  58.  
  59. #define A    0x20)+('A'&0x1f))
  60. #define B    0x20)+('B'&0x1f))
  61. #define C    0x20)+('C'&0x1f))
  62. #define D    0x20)+('D'&0x1f))
  63. #define E    0x20)+('E'&0x1f))
  64. #define F    0x20)+('F'&0x1f))
  65. #define G    0x20)+('G'&0x1f))
  66. #define H    0x20)+('H'&0x1f))
  67. #define I    0x20)+('I'&0x1f))
  68. #define J    0x20)+('J'&0x1f))
  69. #define K    0x20)+('K'&0x1f))
  70. #define L    0x20)+('L'&0x1f))
  71. #define M    0x20)+('M'&0x1f))
  72. #define N    0x20)+('N'&0x1f))
  73. #define O    0x20)+('O'&0x1f))
  74. #define P    0x20)+('P'&0x1f))
  75. #define Q    0x20)+('Q'&0x1f))
  76. #define R    0x20)+('R'&0x1f))
  77. #define S    0x20)+('S'&0x1f))
  78. #define T    0x20)+('T'&0x1f))
  79. #define U    0x20)+('U'&0x1f))
  80. #define V    0x20)+('V'&0x1f))
  81. #define W    0x20)+('W'&0x1f))
  82. #define X    0x20)+('X'&0x1f))
  83. #define Y    0x20)+('Y'&0x1f))
  84. #define Z    0x20)+('Z'&0x1f))
  85.  
  86. #define OPSIZE    127
  87.  
  88. int    optab[]    =        /* nmemonic  operation code table    */
  89. {                /* '.' = 31, '*' = 30, '=' = 29        */
  90.     ((0*0x20)+(29)),PSEUDO,1,
  91.     ((((0*0x20)+(30))*0x20)+(29)),PSEUDO,3,
  92.     ((((((0*A*D*C,IMM2|ABS|ZER|INDX|INDY|ZERX|ABSX|ABSY,0x61,
  93.     ((((((0*A*N*D,IMM2|ABS|ZER|INDX|INDY|ZERX|ABSX|ABSY,0x21,
  94.     ((((((0*A*S*L,ABS|ZER|ZERX|ABSX|ACC,0x02,
  95.     ((((((0*B*C*C,CLASS2,0x90,
  96.     ((((((0*B*C*S,CLASS2,0xb0,
  97.     ((((((0*B*E*Q,CLASS2,0xf0,
  98.     ((((((0*B*I*T,ABS|ZER,0x20,
  99.     ((((((0*B*M*I,CLASS2,0x30,
  100.     ((((((0*B*N*E,CLASS2,0xd0,
  101.     ((((((0*B*P*L,CLASS2,0x10,
  102.     ((((((0*B*R*K,CLASS1,0x00,
  103.     ((((((0*B*V*C,CLASS2,0x50,
  104.     ((((((0*B*V*S,CLASS2,0x70,
  105.     ((((((0*C*L*C,CLASS1,0x18,
  106.     ((((((0*C*L*D,CLASS1,0xd8,
  107.     ((((((0*C*L*I,CLASS1,0x58,
  108.     ((((((0*C*L*V,CLASS1,0xb8,
  109.     ((((((0*C*M*P,IMM2|ABS|ZER|INDX|INDY|ZERX|ABSX|ABSY,0xc1,
  110.     ((((((0*C*P*X,IMM1|ABS|ZER,0xe0,
  111.     ((((((0*C*P*Y,IMM1|ABS|ZER,0xc0,
  112.     ((((((0*D*E*C,ABS|ZER|ZERX|ABSX,0xc2,
  113.     ((((((0*D*E*X,CLASS1,0xca,
  114.     ((((((0*D*E*Y,CLASS1,0x88,
  115.     ((((((0*E*O*R,IMM2|ABS|ZER|INDX|INDY|ZERX|ABSX|ABSY,0x41,
  116.     ((((((0*I*N*C,ABS|ZER|ZERX|ABSX,0xe2,
  117.     ((((((0*I*N*X,CLASS1,0xe8,
  118.     ((((((0*I*N*Y,CLASS1,0xc8,
  119.     ((((((0*J*M*P,ABS|IND,0x40,
  120.     ((((((0*J*S*R,ABS,0x14,
  121.     ((((((0*L*D*A,IMM2|ABS|ZER|INDX|INDY|ZERX|ABSX|ABSY,0xa1,
  122.     ((((((0*L*D*X,IMM1|ABS|ZER|ABSY2|ZERY,0xa2,
  123.     ((((((0*L*D*Y,IMM1|ABS|ZER|ABSX|ZERX,0xa0,
  124.     ((((((0*L*S*R,ABS|ZER|ZERX|ABSX|ACC,0x42,
  125.     ((((((0*N*O*P,CLASS1,0xea,
  126.     ((((((0*O*R*A,IMM2|ABS|ZER|INDX|INDY|ZERX|ABSX|ABSY,0x01,
  127.     ((((((0*P*H*A,CLASS1,0x48,
  128.     ((((((0*P*H*P,CLASS1,0x08,
  129.     ((((((0*P*L*A,CLASS1,0x68,
  130.     ((((((0*P*L*P,CLASS1,0x28,
  131.     ((((((0*R*O*L,ABS|ZER|ZERX|ABSX|ACC,0x22,
  132.     ((((((0*R*O*R,ABS|ZER|ZERX|ABSX|ACC,0x62,
  133.     ((((((0*R*T*I,CLASS1,0x40,
  134.     ((((((0*R*T*S,CLASS1,0x60,
  135.     ((((((0*S*B*C,IMM2|ABS|ZER|INDX|INDY|ZERX|ABSX|ABSY,0xe1,
  136.     ((((((0*S*E*C,CLASS1,0x38,
  137.     ((((((0*S*E*D,CLASS1,0xf8,
  138.     ((((((0*S*E*I,CLASS1,0x78,
  139.     ((((((0*S*T*A,ABS|ZER|INDX|INDY|ZERX|ABSX|ABSY,0x81,
  140.     ((((((0*S*T*X,ABS|ZER|ZERY,0x82,
  141.     ((((((0*S*T*Y,ABS|ZER|ZERX,0x80,
  142.     ((((((0*T*A*X,CLASS1,0xaa,
  143.     ((((((0*T*A*Y,CLASS1,0xa8,
  144.     ((((((0*T*S*X,CLASS1,0xba,
  145.     ((((((0*T*X*A,CLASS1,0x8a,
  146.     ((((((0*T*X*S,CLASS1,0x9a,
  147.     ((((((0*T*Y*A,CLASS1,0x98,
  148.     ((((((0*0x20)+(31))*W*O^((((0*R*D,PSEUDO,2,    /* 0x7cab */
  149.     ((((((0*0x20)+(31))*B*Y^((((0*T*E,PSEUDO,0,    /* 0x7edc */
  150.     ((((((0*0x20)+(31))*P*A^((((0*G*E,PSEUDO,7,    /* 0x7ee4 */
  151.     ((((((0*0x20)+(31))*D*B^((((0*Y*T,PSEUDO,6,    /* 0x7fb6 */
  152.     ((((((0*0x20)+(31))*N*L^((((0*S*T,PSEUDO,5,    /* 0x7fb8 */
  153.     ((((((0*0x20)+(31))*L*I^((((0*S*T,PSEUDO,4,    /* 0x7ffd */
  154.     0x7fff,0,0,
  155.     0x7fff,0,0,
  156.     0x7fff,0,0,
  157.     0x7fff,0,0,
  158.     0x7fff,0,0,
  159.     0x7fff,0,0,
  160.     0x7fff,0,0,
  161.     0x7fff,0,0,
  162.     0x7fff,0,0,
  163.     0x7fff,0,0,
  164.     0x7fff,0,0,
  165.     0x7fff,0,0,
  166.     0x7fff,0,0,
  167.     0x7fff,0,0,
  168.     0x7fff,0,0,
  169.     0x7fff,0,0,
  170.     0x7fff,0,0,
  171.     0x7fff,0,0,
  172.     0x7fff,0,0,
  173.     0x7fff,0,0,
  174.     0x7fff,0,0,
  175.     0x7fff,0,0,
  176.     0x7fff,0,0,
  177.     0x7fff,0,0,
  178.     0x7fff,0,0,
  179.     0x7fff,0,0,
  180.     0x7fff,0,0,
  181.     0x7fff,0,0,
  182.     0x7fff,0,0,
  183.     0x7fff,0,0,
  184.     0x7fff,0,0,
  185.     0x7fff,0,0,
  186.     0x7fff,0,0,
  187.     0x7fff,0,0,
  188.     0x7fff,0,0,
  189.     0x7fff,0,0,
  190.     0x7fff,0,0,
  191.     0x7fff,0,0,
  192.     0x7fff,0,0,
  193.     0x7fff,0,0,
  194.     0x7fff,0,0,
  195.     0x7fff,0,0,
  196.     0x7fff,0,0,
  197.     0x7fff,0,0,
  198.     0x7fff,0,0,
  199.     0x7fff,0,0,
  200.     0x7fff,0,0,
  201.     0x7fff,0,0,
  202.     0x7fff,0,0,
  203.     0x7fff,0,0,
  204.     0x7fff,0,0,
  205.     0x7fff,0,0,
  206.     0x7fff,0,0,
  207.     0x7fff,0,0,
  208.     0x7fff,0,0,
  209.     0x7fff,0,0,
  210.     0x7fff,0,0,
  211.     0x7fff,0,0,
  212.     0x7fff,0,0,
  213.     0x7fff,0,0,
  214.     0x7fff,0,0,
  215.     0x7fff,0,0
  216. };
  217.  
  218. int    step[] =
  219. {
  220.     3*((OPSIZE+1)/2),
  221.     3*((((OPSIZE+1)/2)+1)/2),
  222.     3*((((((OPSIZE+1)/2)+1)/2)+1)/2),
  223.     3*((((((((OPSIZE+1)/2)+1)/2)+1)/2)+1)/2),
  224.     3*((((((((((OPSIZE+1)/2)+1)/2)+1)/2)+1)/2)+1)/2),
  225.     3*(2),
  226.     3*(1),
  227.     0
  228. };
  229.